<template>
    <!-- 专门用于小组件测试的地方,随改随查 -->
    <div class="navigation-container">
        <header>
            <a href="#" class="logo">Logo</a>
            <div class="group">
                <ul class="navigation">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">Serivces</a></li>
                    <li><a href="#">Blog</a></li>
                    <li><a href="#">Contact</a></li>
                </ul>
                <div class="search">
                    <span class="icon">
                        <ion-icon ref="searchBtnRef" name="search-outline" class="search-btn" @click="searchBtn"></ion-icon>
                        <ion-icon ref="closeBtnRef"name="close-outline" class="close-btn" @click="closeBtn"></ion-icon>
                    </span>
                    <ion-icon name="menu-outline" class="menuToggle"></ion-icon>
                </div>
                
            </div>
            <div class="searchBox" ref="searchBoxRef">
                <input type="text" placeholder="Search Here...">
            </div>

        </header>
    </div>

</template>

<script setup lang="ts">
import {ref} from 'vue';
const searchBoxRef = ref()
const closeBtnRef = ref()
const searchBtnRef = ref()
const searchBtn = function(){
    searchBoxRef.value.classList.add('active')
    closeBtnRef.value.classList.add('active')
    searchBtnRef.value.classList.add('active')
}
function closeBtn(){
    searchBoxRef.value.classList.remove('active')
    closeBtnRef.value.classList.remove('active')
    searchBtnRef.value.classList.remove('active')
}
</script>

<style scoped>
.navigation-container {
    background: #dee1e2;
    min-height: 100vh;
    /* overflow-x: hidden; */
}

header {
    position: absolute;
    top: 0;
    left: 0;
    height: 80px;
    background: #fff;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 15px 15px rgba(0, 0, 0, 0.05);
}

.logo {
    color: #333;
    text-decoration: none;
    font-size: 1.5em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.group{
    display: flex;
    align-items: center;
}

header ul {
    position: relative;
    display: flex;
    gap: 30px;
}

header ul li {
    list-style: none;
}

header ul li a {
    position: relative;
    text-decoration: none;
    font-size: 1em;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

header ul li a::before {
    content: "";
    position: absolute;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background: #333;
    transform: scaleX(0);
    transition: transform 0.5s ease-in-out;
    transform-origin: right;
}

header ul li a:hover::before {
    transform: scaleX(1);
    transform-origin: left;
}
header .search{
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    z-index: 10;
    cursor: pointer;
}
.searchBox{
    position: absolute;
    right: -100%;
    width: 100%;
    height: 100%;
    display: flex;
    background: #fff;
    align-items: center;
    padding: 0 30px;
    transition: 0.5s ease-in-out;
}
.searchBox.active{
    right: 0;
}
.searchBox input{
    width: 100%;
    border: none;
    outline: none;
    height: 50px;
    color: #333;
    font-size: 1.25em;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
}
.search-btn{
    position: relative;
    left: 30px;
    top: 2.5px;
    transition: 0.5s ease-in-out;
}
.search-btn.active{
    left: 0;
}
.close-btn{
    opacity: 0;
    visibility: hidden;
    transition: 0.5s;
    scale: 0;
}
.close-btn.active{
    opacity: 1;
    visibility: visible;
    transition: 0.5s;
    scale: 1;
}
.menuToggle{
    position: relative;
    display: none;
}
@media(max-width: 600px){
    header .navigation{
        position: relative;
        opacity: 0;
        visibility: hidden;
        /* left: 100%; */
    }
    .menuToggle{
        position: absolute;
        display: block;
        cursor: pointer;
        transform: translateX(30px);
        z-index: 10;
    }
    .search-btn{
        left: 0;
    }
}

</style>
